define(function (require, exports, module) {

    // 通过 require 引入依赖
    // var $ = require('jquery');
    require('common');
    require('sui');
    require('md5');
    var template = require('template');

    $('#form-register').validate({
        success: function () {
            register();
            return false;
        }
    });

    $(document).on('click', '.checkbox-pretty', function () {
        if ($('.agree').prop('checked')) {
            $('.register-button').removeAttr('disabled');
        } else {
            $('.register-button').prop('disabled', 'disabled');
        }
    });

    function register() {
        var data = $("#form-register").serialize();
        $('.register-button').prop('disabled', 'disabled');
        $.post('/register/addRegister', data, function (o) {
            switch (o.code) {
                case 0:
                    window.location.href = '/user';
                    break;
                default:
                    toastError('注册失败');
                    $('.register-button').removeAttr('disabled');
            }
        });
    }
});